import { post } from '@/utils/request'

export async function uploadFile(params) {
  var form = new FormData()
  for (var key in params) {
    form.append(key, params[key])
  }
  return await post('admin/upload_file', form, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export async function addNode(args) {
  return await post('add/mysql-server', args)
}

export async function getNodes(args) {
  return await post('servers', args)
}

export async function startTrain(args) {
  return await post('train/start', args)
}

export async function mysqlStatus(args) {
  return await post('server/mysql/status', args)
}

export async function mysqlSlowSqls(args) {
  return await post('server/mysql-slowsqls', args)
}

export async function mysqlSlowSqlsInTimeQuantum(args) {
  return await post('server/mysql-slowsql/time-quantum', args)
}

export async function mysqlSlowSqlsInTimeQuantumRecently(args) {
  return await post('server/mysql-slowsql/time-quantum/recently', args)
}

export async function mysqlSlowSqlsTimeDistribution(args) {
  return await post('server/mysql-slowsql/time-distribution', args)
}

export async function serverOsState(args) {
  return await post('server/os/state', args)
}

export async function serverOsStateHistory(args) {
  return await post('server/os/state/history', args)
}

export async function startBenchmark(args) {
  return await post('start/benchmark', args)
}

export async function startOptimizeArameters(args) {
  return await post('train/optimize-arameters', args)
}

export async function optimizeArametersHistory(args) {
  return await post('train/optimize-arameters/history', args)
}

export async function mysqlServers(args) {
  return await post('mysql-servers', args)
}

export async function mysqlServersSimpleInfo(args) {
  return await post('mysql-servers/simpleinfo', args)
}

export async function mysqlDetectorAndDiagnostic(args) {
  return await post('mysql/detector_diagnostic', args)
}

export async function addMysqlServer(args) {
  return await post('add/mysql-server', args)
}

export async function removeMysqlServer(args) {
  return await post('remove/mysql-server', args)
}

export async function modifyMysqlServer(args) {
  return await post('modify/mysql-server', args)
}

export async function pgsqlServers(args) {
  return await post('pgsql-servers', args)
}

export async function pgsqlServersSimpleInfo(args) {
  return await post('pgsql-servers/simpleinfo', args)
}

export async function addPgsqlServer(args) {
  return await post('add/pgsql-server', args)
}

export async function removePgsqlServer(args) {
  return await post('remove/pgsql-server', args)
}

export async function modifyPgsqlServer(args) {
  return await post('modify/pgsql-server', args)
}

// export async function pgsqlSlowSqls(args) {
//   return await post('server/pgsql-slowsqls', args)
// }

export async function alarmHistoary(args) {
  return await post('alarm/history', args)
}

export async function alarmHistoaryRecently(args) {
  return await post('alarm/history-recently', args)
}

export async function sqlExplain(args) {
  return await post('sql/explain', args)
}

export async function sqlIndexSelection(args) {
  return await post('index-selection', args, { 'ignoreCode': true })
}

export async function sqlPlans(args) {
  return await post('plans', args)
}

export async function pgsqlWorkloadAdd(args) {
  return await post('pgsql/workload-add', args)
}

export async function pgsqlWorkloadUpdate(args) {
  return await post('pgsql/workload-update', args)
}

export async function pgsqlWorkloadDelete(args) {
  return await post('pgsql/workload-delete', args)
}

export async function pgsqlWorkloads(args) {
  return await post('pgsql/workloads', args)
}

export async function mysqlWorkloadAdd(args) {
  return await post('mysql/workload-add', args)
}

export async function mysqlWorkloadUpdate(args) {
  return await post('mysql/workload-update', args)
}

export async function mysqlWorkloadDelete(args) {
  return await post('mysql/workload-delete', args)
}

export async function mysqlWorkloads(args) {
  return await post('mysql/workloads', args)
}

export async function mysqlAnomalyTrigger(args) {
  return await post('mysql/anomaly-trigger', args, { timeout: 6000000 })
}

export async function pgsqlSlowSqls(args) {
  return await post('pgsql/slowsqls', args)
}

export async function pgsqlSlowSqlsCount(args) {
  return await post('pgsql/slowsqls-count', args)
}

export async function pgsqlSlowSqlsTimeDistribution(args) {
  return await post('pgsql/slowsqls-time-distribution', args)
}

export async function osProgressStateHistory(args) {
  return await post('os/progress-state/history', args)
}

export async function pgsqlDetectorAndDiagnostic(args) {
  return await post('pgsql/detector_diagnostic', args)
}
